import { BasicMangeType } from '@/interface/common'
import { createStore } from 'vuex'
import { CommitInterface } from '@/interface/store'
// 读取modules文件中的内容,并通过require.context读取文件组成完成的vuex-modules
const moduleCreator = function () {
  const modules: BasicMangeType.Data<CommitInterface<string>> = {}
  const content = require.context('./modules', true, /\.ts|js$/)
  const files = content.keys().map(key => content(key))
  files.forEach(file => {
    modules[file.default.name] = file.default
  })
  return modules
}
moduleCreator()
export default createStore({
  modules: moduleCreator()
})
